package com.qfedu.zf.user.controller;


import cn.hutool.core.convert.NumberWithFormat;
import com.qfedu.zf.common.config.SystemConfig;
import com.qfedu.zf.common.utils.JwtUtil;
import com.qfedu.zf.common.vo.R;
import com.qfedu.zf.user.mapper.CouponMapper;
import com.qfedu.zf.user.mapper.ReportMapper;
import com.qfedu.zf.user.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zym
 * @since 2024-06-20
 */
@RestController
@RequestMapping("/user")
public class ReportController {

    @Autowired
    private ReportMapper reportMapper;
    @Autowired
    private ReportService reportService;

    @RequestMapping("/report/list")
    public R selectByReportList(HttpServletRequest request){
        String header = request.getHeader(SystemConfig.HEADER_TOKEN);
        Integer userId = ((NumberWithFormat) JwtUtil.parseToken(header, "id")).intValue();
        return R.ok(reportService.selectReportVOList(userId));
    }

    @RequestMapping("/beReport/list")
    public R beReport(HttpServletRequest request){
        String header = request.getHeader(SystemConfig.HEADER_TOKEN);
        Integer userId = ((NumberWithFormat) JwtUtil.parseToken(header, "id")).intValue();
        return R.ok(reportService.beReport(userId));
    }
}

